import QtQuick
import QtQuick.Controls
import "./CustomControls"

Window {
    id: root
    property int pageIndex: ui.CPP_PageIndex
    property int prevPageIndex: ui.CPP_PrevPageIndex

    // 去掉标题栏和边框
    flags: Qt.FramelessWindowHint
    width: 1024
    height: 600
    title: qsTr("Hello World")
    //visibility: Window.FullScreen  //全屏显示
    visible: true
    

    Rectangle {
        anchors.fill: parent
        color: "#1F2335"
    }
    Loader {
        id: pageLoader
        anchors.fill: parent
        z: 0
        visible: true
    }

    // 引用 `SlidingArea` 并指定动画的目标对象
    SlidingArea {
        //animationTarget: pageLoader  // 设置动画目标为 `pageLoader`
        heightValue: 200
        widthValue: 1024
        z: 1
    }
    Rpi{
        id: rpi
        visible: false
    }
    //界面切换逻辑
    onPageIndexChanged: {
        console.log("onPageIndexChanged")
        switch(pageIndex)
        {
            case ui.CPP_PAGE_SETTING:
            {
                console.log("to setting")
                pageLoader.source = "./Setting.qml"
            }break
            case ui.CPP_PAGE_HOME:
            {
                console.log("to home")
                pageLoader.source = "./Home.qml"
            }break
            case ui.CPP_PAGE_PRI:
            {
                console.log("to rpi")
                pageLoader.source = "./Rpi.qml"
            }break
            case ui.CPP_PAGE_TEST:
            {
                console.log("to test")
                pageLoader.source = "./Test.qml"
            }break
            default:
            {
                console.log("Unkonw Page")
            }break
        }
    }

    Component.onCompleted: {
        console.log("width : ",root.width)
        console.log("height : ",root.height) 
        //pageLoader.source = "Setting.qml"
        //root.setCursor(Qt.BlankCursor);  // 隐藏鼠标指针
    }


}
